Showing posts with label Editor. Show all posts
Showing posts with label Editor. Show all posts
Saturday, January 2, 2016
Vi Error 'E185: Cannot find color scheme 'morning' in freshly installed ubuntu 14.04.3
Copied all ~/.vim folder to newly installed ubuntu box. But vi is complaining on start up.
"E185: Cannot find color scheme 'morning'"
Because at default it's using vim.tiny.
qyang@ubuntu:~$ ll /etc/alternatives/vi
lrwxrwxrwx 1 root root 17 Dec 6 13:24 /etc/alternatives/vi -> /usr/bin/vim.tiny*
In old ubuntu box:
qyang@lgm-pc:~$ ll /etc/alternatives/vi
lrwxrwxrwx 1 root root 18 Jun 15 2015 /etc/alternatives/vi -> /usr/bin/vim.gnome
Installing vim-gnome fixed this issue. ($sudo apt-get install vim-gnome)
Thursday, January 24, 2013
Nano editor under Linux
[1] How to geek.
The Beginner’s Guide to Nano, the Linux Command-Line Text Editor
New to the Linux command-line? Confused by all of the other advanced text editors? How-To Geek’s got your back with this tutorial to Nano, a simple text-editor that’s very newbie-friendly.
When getting used to the command-line, Linux novices are often put off by other, more advanced text editors such as vim and emacs. While they are excellent programs, they do have a bit of a learning curve. Enter Nano, an easy-to-use text editor that proves itself versatile and simple. Nano is installed by default in Ubuntu and many other Linux distros and works well in conjunction with sudo, which is why we love it so much.
Running Nano
You can run nano in two ways. To open nano with an empty buffer, just type in “nano” at the command prompt.
You can also use the following syntax:
nano /path/to/filenameNano will follow the path and open that file if it exists. If it does not exist, it’ll start a new buffer with that filename in that directory.
Let’s take a look at the default nano screen.
At the top, you’ll see the name of the program and version number, the name of the file you’re editing, and whether the file has been modified since it was last saved. If you have a new file that isn’t saved yet, you’ll see “New Buffer.” Next, you’ll see the contents of your document, a body of text. The third-line from the bottom is a “system message” line that displays information relevant to the program executing a function. Here, you can see that it says “New File.” Lastly, the final two rows at the bottom are what make this program very user-friendly: the shortcut lines.
It’s a WYSIWYG editor; “what you see is what you get.” What you type directly goes into the text input, unless you modify it with a key like Control or Meta. It’s pretty simple, so type some text out, or copy something and paste it into your terminal so we have something to play with.
Shortcuts
Program functions are referred to as “shortcuts” in nano, such as saving, quitting, justifying, etc. The most common ones are listed at the bottom of the screen, but there are many more that aren’t. Note that nano does not use the Shift key in shortcuts. All shortcuts use lowercase letters and unmodified number keys, so Ctrl+G is NOT Ctrl+Shift+G.Hit Ctrl+G to bring up the Help documentation and scroll down to see a list of valid shortcuts.
When you’re done looking at the list, hit Ctrl+X to exit help.
Let’s say you’re working on a new text file, or “buffer,” and you want to save it. This is called “writing out” and is executed by hitting Ctrl+O. You’ll be prompted for a filename to use, and the shortcuts at the bottom will change to reflect what you can enter to complete this particular command.
If you want to insert the contents of another file into your current buffer, you’d type Ctrl+R.
You can cancel both of the previous commands by typing Ctrl+C.
You can hit Escape twice instead of holding down the Control key, if you have trouble doing that. There are also some commands that require use of the Meta key. On most keyboard layouts, Meta equates to the Alt button.
When you want to quit nano, you just hit Ctrl+X. Nano will politely ask you if you want to save your buffer, and you can cancel this action as well.
Navigation
Now that we’ve got a hang of shortcuts, let’s get used to moving around a text file very quickly. Of course, you can always use the Home, End, Page Up, Page Down, and the arrow keys to get around, but that requires moving your fingers from the letters that we all love so much.To move the cursor forward or backward, you can type Ctrl+F and Ctrl+B. To move up and down one line at a time, you can type Ctrl+P and Ctrl+N. In other words, you can use those keys instead of the Right, Left, Up, and Down arrows, respectively. Missing the Home and End keys? You can use Ctrl+A and Ctrl+E. Want to move pages at a time instead? Ctrl+V moves down a page, and Ctrl+Y moves up a page.
But wait, there’s more! To move forward and backward one word at a time, you can use Ctrl+Space and Meta+Space (remember, that’s Alt+Space). And, if you’re really in a rush, you can hit Ctrl+_ and then type in the line number, a comma, and the column number to jump straight there.
If you want to see where your cursor currently is, sort of like nano-GPS, hit Ctrl+C.
Copying, Cutting, and Pasting
When we want to copy text in graphical environment, we highlight it with the cursor. Similarly, in nano we “mark” it by using the Ctrl+^ command. You simply move the cursor to where you want to start marking, and then you hit Ctrl+^ to “set” it. This will mark everything between the starting point up to and NOT including the cursor.Note that the cursor is on the empty space, and copying/cutting will not include this space. You can also mark backwards from your “set” point. Be careful, however, as you can edit text while your marking. If you messed up, just hit Ctrl+^ again to unset the marker and you can start over.
To copy the marked text, hit Meta+^. If, instead, you want to cut the text, hit Ctrl+K.
To Paste your text, move the cursor to a suitable position and hit Ctrl+U.
If you want to remove an entire line of text, simply hit Ctrl+K without highlighting anything. This sometimes comes in handy when editing configuration files.
Some Extra Shortcuts
You know how in notepad, you can force long lines of text to wrap-around into what look like paragraphs? You can toggle that feature in nano with the Meta+L shortcut. Since line wrapping is set to “on” by default, this usually comes in handy in the opposite way; for example, you’re writing a config file and want to disable line-wrapping.You can see that the line the cursor is on has a “$” at both the beginning and end. This signifies that there’s more text both before and after the portion being displayed on screen.
If you want to search for a text string, hit Ctrl+W, and enter your search term. This search can then be cancelled mid-execution by hitting Ctrl+C without destroying your buffer.
The previous search term appears in the square brackets, and leaving the line blank and hitting Enter will repeat that last search.
And after you get really comfortable, you can turn that helpful section at the bottom off by hitting Meta+X to get more screen space for editing!
Some History
Nano was designed to be similar in look and feel to another program called Pico. Pico was the default text editor of Pine, an email program from back in the day that wasn’t distributed with a GPL-friendly license. This meant that redistribution was somewhat of a fuzzy area, and so the TIP project was born. “TIP Isn’t Pico” added some functionality that Pico lacked and was licensed for free distribution, and over time, became the nano we love to use today. For more information, check out the Nano Project’s History section on their FAQ.The strength of nano lies in its simplicity of use. The shortcuts work just like in GUI-based word processors like Word and Open Office, so it’s just a matter of learning which ones do what. Everything outside of that is just simple text-editing. Next time you have to edit stuff on the command-line, we hope that you’ll be more comfortable with it now that you’ve gotten familiar with nano.
Sunday, October 10, 2010
Eclipse Usage and shortcut
[1]Eclipse.Org
CTRL+L go to line number
ISSUE: eclipse overlaps the location of another project [1]
---------------------------------------------------------
---My solution-----
If it's under, then must tick 'using default workspace', and just give the directory name 'LIQGateWay_Dnp3_Porint' as the project name, then it won't report "...eclipse overlaps the location of another project..." as it happened when you untick using default workspace, but still choose folder under .
---Other suggestions----
ONE: Check file '/home/q.yang/EclipseCDT/qywkspace/LIQGateWay_Dnp3_Porting/.metadata'
TWO: Check file '/.metadata/plugins/org.eclipse.core.resources/.projects'
THREE:
Workaround the problem:
1. Go to "%ECLIPSE_HOME%\configuration\.settings" and delete the workspace listed at the key RECENT_WORKSPACES
2. Restart Eclipse, go to File>Switch Workspace>Other... and select your workspace dir again
3. Now I could create new projects as always
CTRL+L go to line number
ISSUE: eclipse overlaps the location of another project [1]
---------------------------------------------------------
---My solution-----
If it's under
---Other suggestions----
ONE: Check file '/home/q.yang/EclipseCDT/qywkspace/LIQGateWay_Dnp3_Porting/.metadata'
TWO: Check file '
THREE:
Workaround the problem:
1. Go to "%ECLIPSE_HOME%\configuration\.settings" and delete the workspace listed at the key RECENT_WORKSPACES
2. Restart Eclipse, go to File>Switch Workspace>Other... and select your workspace dir again
3. Now I could create new projects as always
Wednesday, September 15, 2010
Vi / Vim Notes
[1] vim.org tagbar plugin
[2] vimawesome.com vim plugin\
[3] linux.com vim-101-a-beginners-guide-to-vim
[4] derickbailey/2010/04/23/using-vim-as-your-c-code-editor-from-visual-studio/
[5] cscope.sourceforge.net/cscope_vim_tutorial.html
qyang@lubuntu-laptop:~$ tree ~/.vim
/home/qyang/.vim
├── autoload
│ ├── acp.vim
│ └── tagbar.vim
├── doc
│ ├── acp.jax
│ ├── acp.txt
│ ├── tagbar.txt
│ ├── tags
│ └── tags-ja
├── plugin
│ ├── cscope_maps.vim
│ └── tagbar.vim
├── plugins
│ ├── acp.vim
│ ├── cctree.vim
│ ├── ming.vim
│ └── qt.vim
├── README.md
└── syntax
├── python.vim
└── tagbar.vim
ming.vim
set showcmd
set ruler
set nocompatible
set ignorecase smartcase incsearch hlsearch
set nowrap
set smartindent
set backspace=indent,eol,start
function Setcohda(...)
set tabstop=2 shiftwidth=2
set expandtab
endfunction
function Setlinux(...)
set tabstop=8 shiftwidth=8
set noexpandtab
endfunction
command Cohda call Setcohda()
command Linux call Setlinux()
autocmd FileType cpp Cohda
autocmd FileType make set noexpandtab tabstop=8
autocmd FileType python set tabstop=4 shiftwidth=4 noexpandtab
noremap :!make
inoremap :!make
qt.vim
------------------------------------
Generate cscope.out on root directory of source code project, then start vim from that root directory. All symbols index in cscope.out can be used by vim now.
Try below to jump straight to the file including 'main' symbol
Insert following code into makefile to generate cscope.out via make.
DISPLAY TAB
---------------------
Not quite work correctly to show all tabs
:SeeTab vim.wikia.com
OPEN MULTIPLE FILES FROM CMD LINE
-------------------------
TURN ON LINE NUMBER
------------------------
:set number
REPLACE A STRING
-------------------
:1,$s/word1/word2/gc IN A WHOLE FILE
:n1,n2s/word1/word2/gc IN BETWEEN LINE 'n1' and 'n2', special character use '\' prefix. (e.g.,:1,$s/word\[/word1\[/gc, replace 'word[' with 'word1[' )
COMMAND MODE
---------------------
'g0' -- go zero, go to head of line;
'g$' -- go to end of line;
'G' -- go to end of this file;
'H' -- go to top of screen;
'M' -- go to middle of screen;
'L' -- go to bottom of screen;
'nG' -- go to line number 'n'
'/word' -- search a string 'word' forward;
'?word' -- search a string 'word' backward;
'nyy' -- yank/copy n lines after cursor;
'p' -- paste yanked contens one line below cursor;
'dd' -- delete current line;
'nd' -- delete n lines after cursor;
DELETE/COPY(YANK) A BLOCK OF TEXT
----------------------------
The ‘mark command can be very useful when deleting a long series of lines.To
delete a long series of lines, follow these steps:
1. Move the cursor to the beginning of the text you want to delete.
2. Mark it using the command ma. (This marks it with mark a.)
3. Go to the end of the text to be removed. Delete to mark a using the command
d’a.
Note:There is nothing special about using the a mark. Any mark from a to z
may be used.
BACK TO PREVIOUSLY VISITED LOCATION previous view
-----------------------------
Ctrl + O
Ctrl + I (tab)
Jumping_to_previously_visited_locations
JUMP TO SYMBOL DEFINITION when ctags/cscope enabled
------------------------------
Ctrl + ]
Ctrl + T
A 05 Vi Exercise
===============================
[1] http://stackoverflow.com/questions/1737163/traversing-text-in-insert-mode
Insert mode and navigation mode switch
----------------------------------------
ESC or Ctrl+[
Navigation Fast
--------------------
15 + h go backward 15 characters
5 + j go forward 5 lines
Ctrl+o + 2 + b navigate two words back without leaving insert mode
Ctrl+o will give you chance to run one vi command at navigation
mode, then return to insert mode automatically.
'+. back to previous editing place after navigation
Type 20 '-' delete backword 9 '-'
----------------------------------------
20 + i + - + ESC
9 + X
'20' set number of execute times
'i' into insert mode
'-' letter or words you want to repeat
'ESC' back to navigation mode will display all insert letters.
'9' set number of exectue times
'X' delete backward, 'x' delete forward
Paste from clip board
-----------------------------------
"+p
" use register
+ clipboard register index
p paste shortcut key
Corret Typo
----------------------
accifently
FfrdA will correct the word from accifently to accidently
'F' find backward 'f' find forward
'f' find letter 'f'
'r' replace current cursor
'd' type correct letter 'd'
'A' back to original edit place
Rewrite word
--------------------
you accidentlly typed
you intentially typed
you intertially typed
ESC + 2 + b + c + w intentially + ESC + A
Write words in multiple lines
--------------------
[2] http://vim.wikia.com/wiki/Inserting_text_in_multiple_lines
hello
hello
hello
hel:added:loappend
hel:added:loappend
hel:added:loappend
hllo hello append
hllo hello append
hllo hello append
Ctrl+v + navigate coursor to 'l' + j + j + j + I + :added: + ESC
Ctrl+v + navigate coursor to 'o' + l + A + Ctrl+R + "
Ctrl+v + select block you want to delete + d
'Ctrl+v' visual block mode.
'I' insert before current cursor in visual block mode.
'A' append after current cursor in visual block mode.
'Ctrl + R + "' past yank register in insert mode
'Ctrl + R + +' past clipboard insert mode.
[2] vimawesome.com vim plugin\
[3] linux.com vim-101-a-beginners-guide-to-vim
[4] derickbailey/2010/04/23/using-vim-as-your-c-code-editor-from-visual-studio/
[5] cscope.sourceforge.net/cscope_vim_tutorial.html
qyang@lubuntu-laptop:~$ tree ~/.vim
/home/qyang/.vim
├── autoload
│ ├── acp.vim
│ └── tagbar.vim
├── doc
│ ├── acp.jax
│ ├── acp.txt
│ ├── tagbar.txt
│ ├── tags
│ └── tags-ja
├── plugin
│ ├── cscope_maps.vim
│ └── tagbar.vim
├── plugins
│ ├── acp.vim
│ ├── cctree.vim
│ ├── ming.vim
│ └── qt.vim
├── README.md
└── syntax
├── python.vim
└── tagbar.vim
ming.vim
qt.vim
------------------------------------
: colorscheme morning
: syntax on
: autocmd FileType * set formatoptions=tcql nocindent comments&
: autocmd InsertEnter * colorscheme blue
: autocmd InsertLeave * colorscheme morning
: set autowrite
: ab #d #define
: ab #i #include
: ab #b /********************************************************
: ab #e ^H^H********************************************************/
: ab #l /*------------------------------------------------------*/
: set sw=4
: set notextmode
: set notextauto
: set hlsearch
: set incsearch
: set textwidth=150
: au BufWinEnter * let w:m1=matchadd('Search','\%<151v .="">77v', -1)
: au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>150v.\+', -1)
: autocmd FileType c,cpp set formatoptions=croql cindent comments=sr: /*,mb: *.ex: */,: //
: set nowrap
: match ErrorMsg '\%>80v.\+'
: set expandtab
: set shiftwidth=2
: set softtabstop=2
: map : s/^/\/\//
: map : s/^\/\///
: set smartcase
: set ic 151v>
: nmap :TagbarToggle func! DeleteTrailingWS() exe "normal mz" %s/\s\+$//ge exe "normal `z" endfunc autocmd BufWrite *.py : call DeleteTrailingWS()
Generate cscope.out on root directory of source code project, then start vim from that root directory. All symbols index in cscope.out can be used by vim now.
Try below to jump straight to the file including 'main' symbol
$vi -t main
Insert following code into makefile to generate cscope.out via make.
$make cscope -f MakefileName
# Make software
#
# Generate csope files
cscope: cscope.out
cscope.out: cscope.files
@cscope -R -b -i $<
cscope.files:
@find am335x -name "*.[ch]" -not -path "*/bootloader/*" > $@ && \
find libs -name "*.[ch]" -not -path "*/kissfft/*" >> $@ && \
find am335x -name "*.cpp" -o -name "*.h" -not -path "*/bootloader/*" >>
find rtos -name "*.c" -o -name "*.h" -o -name "*.cpp" >> $@
clean:
@rm cscope.*
DISPLAY TAB
---------------------
Not quite work correctly to show all tabs
:SeeTab vim.wikia.com
OPEN MULTIPLE FILES FROM CMD LINE
-------------------------
qyang@lubuntu-laptop:~/Git_Local_Sandbox/PcapPlot$ vi -g -p *.sh *.py 12 files to edit
TURN ON LINE NUMBER
------------------------
:set number
REPLACE A STRING
-------------------
:1,$s/word1/word2/gc IN A WHOLE FILE
:n1,n2s/word1/word2/gc IN BETWEEN LINE 'n1' and 'n2', special character use '\' prefix. (e.g.,:1,$s/word\[/word1\[/gc, replace 'word[' with 'word1[' )
COMMAND MODE
---------------------
'g0' -- go zero, go to head of line;
'g$' -- go to end of line;
'G' -- go to end of this file;
'H' -- go to top of screen;
'M' -- go to middle of screen;
'L' -- go to bottom of screen;
'nG' -- go to line number 'n'
'/word' -- search a string 'word' forward;
'?word' -- search a string 'word' backward;
'nyy' -- yank/copy n lines after cursor;
'p' -- paste yanked contens one line below cursor;
'dd' -- delete current line;
'nd' -- delete n lines after cursor;
DELETE/COPY(YANK) A BLOCK OF TEXT
----------------------------
The ‘mark command can be very useful when deleting a long series of lines.To
delete a long series of lines, follow these steps:
1. Move the cursor to the beginning of the text you want to delete.
2. Mark it using the command ma. (This marks it with mark a.)
3. Go to the end of the text to be removed. Delete to mark a using the command
d’a.
Note:There is nothing special about using the a mark. Any mark from a to z
may be used.
BACK TO PREVIOUSLY VISITED LOCATION previous view
-----------------------------
Ctrl + O
Ctrl + I (tab)
Jumping_to_previously_visited_locations
JUMP TO SYMBOL DEFINITION when ctags/cscope enabled
------------------------------
Ctrl + ]
Ctrl + T
A 05 Vi Exercise
===============================
[1] http://stackoverflow.com/questions/1737163/traversing-text-in-insert-mode
Insert mode and navigation mode switch
----------------------------------------
ESC or Ctrl+[
Navigation Fast
--------------------
15 + h go backward 15 characters
5 + j go forward 5 lines
Ctrl+o + 2 + b navigate two words back without leaving insert mode
Ctrl+o will give you chance to run one vi command at navigation
mode, then return to insert mode automatically.
'+. back to previous editing place after navigation
Type 20 '-' delete backword 9 '-'
----------------------------------------
20 + i + - + ESC
9 + X
'20' set number of execute times
'i' into insert mode
'-' letter or words you want to repeat
'ESC' back to navigation mode will display all insert letters.
'9' set number of exectue times
'X' delete backward, 'x' delete forward
Paste from clip board
-----------------------------------
"+p
" use register
+ clipboard register index
p paste shortcut key
Corret Typo
----------------------
accifently
FfrdA will correct the word from accifently to accidently
'F' find backward 'f' find forward
'f' find letter 'f'
'r' replace current cursor
'd' type correct letter 'd'
'A' back to original edit place
Rewrite word
--------------------
you accidentlly typed
you intentially typed
you intertially typed
ESC + 2 + b + c + w intentially + ESC + A
Write words in multiple lines
--------------------
[2] http://vim.wikia.com/wiki/Inserting_text_in_multiple_lines
hello
hello
hello
hel:added:loappend
hel:added:loappend
hel:added:loappend
hllo hello append
hllo hello append
hllo hello append
Ctrl+v + navigate coursor to 'l' + j + j + j + I + :added: + ESC
Ctrl+v + navigate coursor to 'o' + l + A + Ctrl+R + "
Ctrl+v + select block you want to delete + d
'Ctrl+v' visual block mode.
'I' insert before current cursor in visual block mode.
'A' append after current cursor in visual block mode.
'Ctrl + R + "' past yank register in insert mode
'Ctrl + R + +' past clipboard insert mode.
Tuesday, November 18, 2008
Add new Macros in Soure Insight.
First, download Macros from http://www.sourceinsight.com/public/macros/
Macros like utils.em, comment.em,
just add utils.em into your project as one project source file, then after assigning a shortcut key to corresponding functions in utils.em, like, 'alt+(' for uncomment block of codes, 'alt+)' for comment block of codes. You can enjoy some new shortcut keys now powered by the Macros embedded into source insight.
Macros like utils.em, comment.em,
just add utils.em into your project as one project source file, then after assigning a shortcut key to corresponding functions in utils.em, like, 'alt+(' for uncomment block of codes, 'alt+)' for comment block of codes. You can enjoy some new shortcut keys now powered by the Macros embedded into source insight.
Subscribe to:
Posts (Atom)