Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I tried out vi on ubuntu 8.04 and fedora 10, but don't seem to able to
fix the "return the previous cursor position" when i reopen a file.
Tried out google suggestions but they are not working.
Quote:
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
\ let b:doopenfold = 1 |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
\ let b:doopenfold = 2 |
\ endif |
\ exe JumpCursorOnEdit_foo |
\ endif |
\ endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
\ if exists("b:doopenfold") |
\ exe "normal zv" |
\ if(b:doopenfold > 1) |
\ exe "+".1 |
\ endif |
\ unlet b:doopenfold |
\ endif
augroup END
or
Quote:
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
\ let b:doopenfold = 1 |
\ if (foldlevel(JumpCursorOnEdit_foo) >
foldlevel(JumpCursorOnEdit_foo - 1)) |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
\ let b:doopenfold = 2 |
\ endif |
\ exe JumpCursorOnEdit_foo |
\ endif |
\ endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
\ if exists("b:doopenfold") |
\ exe "normal zv" |
\ if(b:doopenfold > 1) |
\ exe "+".1 |
\ endif |
\ unlet b:doopenfold |
\ endif
augroup END
Strange enough, the vim that comes with CentOS is working very well (comes even with nice text highlighting when I open a Fortran90 file). But I don't find .vimrc file that I can recycle.
Looks like I have a case where the old horse is better than the new ones.
[root@centos52-64-fuj profile.d]# cat /etc/profile.d/vim.sh
if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ]; then
[ -x /usr/bin/id ] || return
[ `/usr/bin/id -u` -le 100 ] && return
# for bash and zsh, only if no alias is already set
alias vi >/dev/null 2>&1 || alias vi=vim
fi
why is ubuntu so unclean? (or whatever you might call it)
After I purge and autoremove vim (hoping that i can get the latest vim),
the vim is still executable in the system.
Quote:
root@ubuntu804-32-dell:/etc# apt-get purge vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package vim is not installed, so not removed
The following packages were automatically installed and are no longer required:
vim-runtime
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 147 not upgraded.
root@ubuntu804-32-dell:/etc# apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
vim-runtime
The following packages will be REMOVED:
vim-runtime
0 upgraded, 0 newly installed, 1 to remove and 147 not upgraded.
After this operation, 23.3MB disk space will be freed.
Do you want to continue [Y/n]? Y
(Reading database ... 114011 files and directories currently installed.)
Removing vim-runtime ...
root@ubuntu804-32-dell:/etc# which vi
/usr/bin/vi
root@ubuntu804-32-dell:/etc# which vim
/usr/bin/vim
the commented lines that allow one to jump to the last position when reopening a file are incorrect. It doesn't act properly if a user remaps g in their .vimrc . It needs an ! after the normal. It should read:
" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
" \| exe "normal! g'\"" | endif
"endif
Notice the ! after normal, that needs to be added so that it doesn't remap the g. Obviously this is only a problem if someone uncomments those lines, and has g remapped in their .vimrc (or vimrc.local in my case).
to reproduce, uncomment those lines in /etc/vim/vimrc and add
noremap g >>j
to /etc/vim/vimrc.local
After doing what this says, I still have
Quote:
ckgan@ubuntu804-32-dell:~$ !v
vim
Error detected while processing /usr/share/vim/vimrc:
line 30:
E10: \ should be followed by /, ? or &
Press ENTER or type command to continue
I think I run of luck today. I am starting to doubt the friendliness of
you-know-what...
Solved.. borrow /etc/vimrc of CentOS5.2 and figure out to put everything
in one line to avoid backslash. And it works now.
Quote:
if has("autocmd")
" When editing a file, always jump to the last cursor position
autocmd BufReadPost * if line("'\"") > 0 && line ("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.